package org.lanqiao.tjut.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.tjut.bean.UsersBean;
import org.lanqiao.tjut.myUtils.MyUtils;
import org.lanqiao.tjut.service.ServiceFactory;

public class UserInfoDelete extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 准备用户进行修改的数据
	
		// 结果跳转页面

		// 删除
		int userId = MyUtils.obj2Int(request.getParameter("uid"));
		// 数据库删除
		int i = ServiceFactory.getUserInfoManagerServiceInstance().deleteUserById(userId);
//		// 跳转页面
//		strJumpPage = "logined/UserInfoManager/userInfoQuery.jsp";
//		
//		// 跳转到修改页面
//		request.getRequestDispatcher(strJumpPage).forward(request, response);
//		
		
		//获取需要显示的所有的数据集合
		List<UsersBean> lstUsers = ServiceFactory.getUserInfoManagerServiceInstance().getAllUsersInfo();
		//将需要显示的结果集放入session缓存中
		request.getSession().setAttribute("lstUsers", lstUsers);
		//清空request缓存中的对象
		request.removeAttribute("usersB");
		//转发到结果显示页面
		request.getRequestDispatcher("logined/UserInfoManager/userInfoQuery.jsp").forward(request, response);
		//response.sendRedirect("logined/UserInfoManager/userInfoAddDetail.jsp");
	}

}
